package com.caijinbang.study.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 使用@Scheduled创建定时任务
 *
 * @author caijb
 * @version 1.0.0
 * @date 2018-05-01 22:46
 */
@Component
@Slf4j
public class ScheduledDemo {

    /**
     * 使用cron表达式出发定时任务(每10s出发一次)
     *
     * @throws Exception
     */
    @Scheduled(cron = "0 0 5 * * ? ")
    public void cron() throws Exception {
        log.info("测试cron执行时间" + new Date(System.currentTimeMillis()));
    }

}
